<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp" %>
<div class="container-fluid am-margin-top">
	<form id="dataDicForm">
        <input type="hidden" name="id"/>
        <div class="form-group">
            <label for="name">名称</label>
            <input type="text" name="name" class="form-control" check-type="required">
        </div>
        <div class="form-group">
            <label for="code">编码</label>
            <input type="text" name="code" class="form-control" check-type="required">
        </div>
        <div class="form-group">
      		<label for="dicAttr">字典类型属性</label>
     		<select class="form-control" name="dicAttr">
				<option value="GB">国家标准字典</option>
				<option value="DB">地方标准字典</option>
				<option value="HB">行业标准字典</option>
				<option value="CUSTOM">自定义字典</option>
				<option value="SYSTEM">系统字典</option>
			</select>
      	</div>
        <div class="form-group">
            <a href="javascript:void(0)" id="dataDicSaveBt"  class="btn btn-primary pull-right">保存</a>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        var dataDicForm = $("#dataDicForm");
        var id = '${param.id}';
        var dicAttr='${param.dicAttr}';
        dataDicForm.validation();
        if (id) {
            $.getJSON(ctx + '/dataDicAction/findDataDicById.do', {id: id}, function (data) {
                webUtils.fullForm({
                    form: dataDicForm,
                    data: data
                });
            });
        }else{
        	webUtils.fullForm({
                form: dataDicForm,
                data: {
                	dicAttr:dicAttr
                }
            });
        }
        $("#dataDicSaveBt").click(function () {
        	if(dataDicForm.valid()){
        		dataDicForm.ajaxSubmit({
                    url: ctx + '/dataDicAction/saveDataDic.do',
                    data: {},
                    type: "POST",
                    success: function (data) {
                        if (data.success) {
                            webUtils.alert("提交成功");
                            top.webUtils.topicPublish("dataDic.edit.success", data);
                        } else {
                        	webUtils.error(data.msg);
                        }
                    }
                });
        	}
        });
    });
</script>
